package com.linkwedo.saas.users;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.linkwedo.saas.domain.Project;
import com.linkwedo.saas.domain.member.User;
import com.linkwedo.saas.util.DateUtil;
import com.opensymphony.xwork2.ActionSupport;


public class AddUserAction extends ActionSupport implements ServletRequestAware{
	private UserService UserService;
	public UserService getUserService() {
		return UserService;
	}

	public void setUserService(UserService UserService) {
		this.UserService = UserService;
	}
	private Integer id;
	private String email;
	private String lastName;
	private String firstName;	
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getWorkPhone() {
		return workPhone;
	}

	public void setWorkPhone(String workPhone) {
		this.workPhone = workPhone;
	}

	public String getMobilePhone() {
		return mobilePhone;
	}

	public void setMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
	}

	public String getHomePhone() {
		return homePhone;
	}

	public void setHomePhone(String homePhone) {
		this.homePhone = homePhone;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getJobTitle() {
		return jobTitle;
	}

	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}

	public String getJobDescription() {
		return jobDescription;
	}

	public void setJobDescription(String jobDescription) {
		this.jobDescription = jobDescription;
	}

	public String getCompanyWebsite() {
		return companyWebsite;
	}

	public void setCompanyWebsite(String companyWebsite) {
		this.companyWebsite = companyWebsite;
	}

	public String getMsn() {
		return msn;
	}

	public void setMsn(String msn) {
		this.msn = msn;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public String getOtherEmail() {
		return otherEmail;
	}

	public void setOtherEmail(String otherEmail) {
		this.otherEmail = otherEmail;
	}

	public Date getRegisterDate() {
		return registerDate;
	}

	public void setRegisterDate(Date registerDate) {
		this.registerDate = registerDate;
	}

	public javax.servlet.http.HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(javax.servlet.http.HttpServletRequest request) {
		this.request = request;
	}
	private String workPhone;
	private String mobilePhone;
	private String homePhone;
	private Integer sex;
	private String birthday;
	private String company;
	private String department;
	private String location;
	private String jobTitle;
	private String jobDescription;
	private String companyWebsite;
	private String msn;
	private String qq;
	private String otherEmail;
	private Date registerDate;
	private javax.servlet.http.HttpServletRequest request;
	public void setServletRequest(HttpServletRequest request) {
		// TODO Auto-generated method stub
		this.request=request;
	}

	private List<User> list;
	public List<User> getList() {
		return list;
	}

	public void setList(List<User> list) {
		this.list = list;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	private static final long serialVersionUID = 8190003683775267839L;
	public String execute() throws Exception {
		firstName=request.getParameter("firstName");
		lastName=request.getParameter("lastName");
		email=request.getParameter("email");
		workPhone=request.getParameter("workPhone");
		mobilePhone=request.getParameter("mobilePhone");
		homePhone=request.getParameter("homePhone");
		sex=Integer.parseInt(request.getParameter("sex"));
		company=request.getParameter("company");
		department=request.getParameter("department");
		location=request.getParameter("location");

		birthday=request.getParameter("birthday");
		jobTitle=request.getParameter("jobTitle");
		jobDescription=request.getParameter("jobDescription");
		companyWebsite=request.getParameter("companyWebsite");
		msn=request.getParameter("msn");
		qq=request.getParameter("qq");
		otherEmail=request.getParameter("otherEmail");
		registerDate= new Date();
		User pro=new User();
		pro.setBirthday(DateUtil.str2Date(birthday,"yyyy-MM-dd HH:mm:ss"));
		pro.setCompany(company);
		pro.setCompanyWebsite(companyWebsite);
		pro.setDepartment(department);
		pro.setEmail(email);
		pro.setFirstName(firstName);
		pro.setJobDescription(jobDescription);
		pro.setJobTitle(jobTitle);
		pro.setLastName(lastName);
		pro.setLocation(location);
		pro.setMobilePhone(mobilePhone);
		pro.setMsn(msn);
		pro.setOtherEmail(otherEmail);
		pro.setQq(qq);
		pro.setRegisterDate(registerDate);
		pro.setSex(sex);
		pro.setWorkPhone(workPhone);
		getUserService().save(pro);
		list=getUserService().findAll();
		return "ok";
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	}
